package hexgame;

public class HexMove {
	HexPlayer player;
	int x;
	int y;
	int cost;
	
	/**
	 * Create a new HexMove.
	 * This move will be invalid if returned from Player.getMove() or if passed to GameLogic.makeMove.
	 * You must use setPlayer();
	 * @param x
	 * @param y
	 */
	public HexMove(int x, int y) {
		this.x = x;
		this.y = y;
	}
	
	/**
	 * Creates a new, potentially valid HexMove.
	 * @param x
	 * @param y
	 * @param player
	 */
	public HexMove(int x, int y, HexPlayer player) {
		this(x, y);
		this.player = player;
	}
	
	public int getX() {
		return x;
	}
	
	public int getY() {
		return y;
	}
	
	public HexPlayer getPlayer() {
		return player;
	}

	@Override
	public int hashCode() {
		return x * 50 + y * 50 + player.ordinal() * 3;
	}
	
	@Override
	public boolean equals(Object object) {
		if(!(object instanceof HexMove)) {
			return false;
		}
		
		HexMove obj = (HexMove) object;
		
		if(obj.x == this.x && obj.y == this.y && obj.player == this.player) {
			return true;
		}
		
		return false;
	}
}
